exports.setImageWatermark = function (req, res) {

    var path = require("path");

    //获取body参数
    var bodyParams = req.routeInfo.bodyParams;

    //根据位置获取最终值
    var position = "SouthEast";
    if (bodyParams.position != undefined) {
        if (bodyParams.position == 'leftTop') {
            position = "NorthWest";
        } else if (bodyParams.position == 'leftBottom') {
            position = "SouthWest";
        } else if (bodyParams.position == 'rightTop') {
            position = "NorthEast";
        } else if (bodyParams.position == 'rightBottom') {
            position = "SouthEast";
        } else if (bodyParams.position == 'center') {
            position = "Center";
        }
    }


    //获取要处理的文件名称
    var imageUrl = path.basename(bodyParams.srcImageUrl);

    //处理完成后的图片名称
    var newFileName = "w_" + imageUrl;

    //打水印-图片
    GM(bodyParams.srcImageUrl)
        .composite(bodyParams.waterMarkUrl)
        .gravity(position)
        .geometry('+5+5')
        .write("./" + config.fileManager.baseDir + "/" + config.uploadImageConfig.imageParocessingDir + "/" + newFileName, function (err) {
            if (err) {
                return RES.errorResponse("文件水印设置失败");
            }
            RES.successResponse(config.server.ip + ":" + config.server.port + "/" + config.uploadImageConfig.imageParocessingDir + "/" + newFileName);
        })

}